var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
            function (t, e) {
                a(t, e);
                function o() {
                    this.constructor = t;
                }
                t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
            }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", { value: !0 });
var r = t("GameEm"),
    s = cc._decorator,
    c = s.ccclass,
    p = s.property,
    l =
        (s.menu,
            (function (t) {
                i(e, t);
                function e() {
                    var e = (null !== t && t.apply(this, arguments)) || this;
                    e.lab = null;
                    e.viewNode = null;
                    e.coinSprite = null;
                    e.addCost = "";
                    e.rewrdKind = r.RewardResKind.jinBi;
                    return e;
                }
                e.prototype.onLoad = function () {
                    this.viewNode.active = !1;
                    this.viewNode.on(cc.Node.EventType.TOUCH_END, this._TouchCancel, this);
                    GameDataValue.getLastLv() >= 2 && this.checkView();
                };
                e.prototype.setSprite = function (t) {
                    SpriteView.setRewardCoin(t, this.coinSprite);
                };
                e.prototype.nextRewardKind = function () {
                    var t = CacheDataManager.getLvUpgradeValueData(r.UpgradeData.adView);
                    Math.random() > t
                        ? (this.rewrdKind = r.RewardResKind.jinBi)
                        : (this.rewrdKind = r.RewardResKind.zhuanShi);
                };
                e.prototype.checkView = function () {
                    var t = this;
                    this.scheduleOnce(function () {
                        t.nextRewardKind();
                        t.updateView();
                        CacheDataManager.checkCost(t.addCost, "1") ? (t.viewNode.active = !0) : (t.viewNode.active = !1);
                        QAudio.play(QAudio.effect_suitcase_appear);
                        t.scheduleOnce(function () {
                            t.viewNode.active = !1;
                            t.unscheduleAllCallbacks();
                            t.checkView();
                        }, 10);
                    }, 60);
                };
                e.prototype.onDestroy = function () {
                    this.viewNode.off(cc.Node.EventType.TOUCH_END, this._TouchCancel, this);
                };
                e.prototype.updateView = function () {
                    this.setSprite(this.rewrdKind);
                    this.getAllCost();
                    this.lab.string = ParseTool.parseAbc(this.addCost);
                };
                e.prototype.getAllCost = function () {
                    var t = CacheDataManager.getLvUpgradeValueData(r.UpgradeData.adViewDounble);
                    switch (this.rewrdKind) {
                        case r.RewardResKind.jinBi:
                            var e = CacheDataManager.getAllAddCost(),
                                o = CacheDataManager.getLevelChapterMul(GameDataValue.getLastLv()),
                                a = "0" == (e = CacheDataManager.mulDot(e, t * o)) ? e : e + "00";
                            this.addCost = a;
                            break;
                        case r.RewardResKind.zhuanShi:
                            this.addCost = "" + Math.floor(10 * t);
                    }
                };
                e.prototype._TouchCancel = function () {
                    var t = this;
                    if (this.viewNode.active) {
                        var e = this.rewrdKind;
                        BannerAd.Instance.ShowVideo(() => {
                            QReport.send("2004");
                            t.unscheduleAllCallbacks();
                            t.viewNode.active = !1;
                            t.checkView();
                            var a = EVUIEffView.moveZhuanShi;
                            switch (e) {
                                case r.RewardResKind.jinBi:
                                    a = EVUIEffView.moveCoin;
                                    break;
                                case r.RewardResKind.zhuanShi:
                                    a = EVUIEffView.moveZhuanShi;
                            }
                            EVUIEffView.emit(
                                a,
                                t.coinSprite.node.convertToWorldSpaceAR(cc.Vec2.ZERO),
                                2,
                                t.addCost,
                                "0"
                            );
                            var i = PlayEffectDo.playCoinNum(
                                t.node.parent,
                                cc.v2(cc.winSize.width / 2, (2 * cc.winSize.height) / 3),
                                QLooperNode.tag_addCoinItem,
                                ParseTool.parseAbc(t.addCost),
                                e
                            );
                            ParseTool.setSortIndex(i, 2e3);
                        });
                        // AdView.showRewardVedioAd(function (o) {
                        //     if (o) {
                        //         QReport.send("2004");
                        //         t.unscheduleAllCallbacks();
                        //         t.viewNode.active = !1;
                        //         t.checkView();
                        //         var a = EVUIEffView.moveZhuanShi;
                        //         switch (e) {
                        //             case r.RewardResKind.jinBi:
                        //                 a = EVUIEffView.moveCoin;
                        //                 break;
                        //             case r.RewardResKind.zhuanShi:
                        //                 a = EVUIEffView.moveZhuanShi;
                        //         }
                        //         EVUIEffView.emit(
                        //             a,
                        //             t.coinSprite.node.convertToWorldSpaceAR(cc.Vec2.ZERO),
                        //             2,
                        //             t.addCost,
                        //             "0"
                        //         );
                        //         var i = PlayEffectDo.playCoinNum(
                        //             t.node.parent,
                        //             cc.v2(cc.winSize.width / 2, (2 * cc.winSize.height) / 3),
                        //             QLooperNode.tag_addCoinItem,
                        //             ParseTool.parseAbc(t.addCost),
                        //             e
                        //         );
                        //         ParseTool.setSortIndex(i, 2e3);
                        //     }
                        // });
                    }
                };
                n([p(cc.Label)], e.prototype, "lab", void 0);
                n([p(cc.Node)], e.prototype, "viewNode", void 0);
                n([p(cc.Sprite)], e.prototype, "coinSprite", void 0);
                return n([c], e);
            })(cc.Component));
o.default = l;
